local mdb = require 'mc.mdb'
local log = require 'mc.logging'
local ctx = require 'mc.context'
local skynet = require 'skynet'

require 'bmc_datasync.json_types.DataSync'

local local_path = '/bmc/kepler/Managers/1/DataSync'
local local_intf = 'bmc.kepler.Managers.DataSync'


local interface_cases = {}
interface_cases.__index = interface_cases

function interface_cases.test_tcp_property_sync(bus)
    log:notice('------- test tcp property sync start -------')
    local client = mdb.get_object(bus, local_path, local_intf)
    local res = client:GetProperties_PACKED(ctx.new(), 1, "Component_BMC_00", "bmc.kepler.Systems.Component"):unpack()
    assert(#res == 2, 'actual: ' .. #res)  -- 查询到2个属性
    log:notice('------- test tcp property sync end -------')
end

function interface_cases.test_dump(bus)
    log:notice('------- test dump start -------')
    local debug_path = '/bmc/kepler/bmc_datasync/MicroComponent'
    local debug_intf = 'bmc.kepler.MicroComponent.Debug'
    local dump_path = skynet.getenv('DUMP_FILE_PATH')
    bus:call('bmc.kepler.bmc_datasync', debug_path, debug_intf, 'Dump', 'a{ss}s', ctx.new(), dump_path)
    local file_sec = require 'utils.file'
    local txt = file_sec.open_s(dump_path .. '/bmc_datasync.txt', 'r')
    assert(txt)
    log:notice('------- test dump end -------')
end

function interface_cases.test_entry(bus)
    log:notice('------- test entry start -------')
    interface_cases.test_tcp_property_sync(bus)
    interface_cases.test_dump(bus)
    log:notice('------- test entry end -------')
end

return interface_cases

